define(['Add'],function(Add){
	function chao(){
		rexiao('热销榜');
		ulSpan();
		
	}
	function rexiao(category){
		$.ajax({
			type : 'GET',
			data : {
				category : category
			},
			url : 'http://h5.yztctech.net/api/axf/apicategory.php',
			success : function(data){
				var objData = JSON.parse(data);
				if(objData.status == 3){
					console.log('无数据');
					$('.menu_ul').html('<div class="wushuju">暂时没有商品</div>');
				}else{
					var obj = objData.data;
					var html = '';
					for(var i in obj){
						html+='<li class="menu_li" id="'+obj[i].id+'"><div class="li_img"><img '+
						'src="http://m.beequick.cn/static/bee/img/m/product_default-5fa101a5.pn'+
						'g" data-src="'+obj[i].img+'"/>'+
						'</div><div class="xiangqing"><div><p class="shuiguo_name">'+obj[i].name+
						'</p><p class="jingxuan"><span>精选</span>'+
						'<i data-num="'+obj[i].pm_desc.length+'">'+obj[i].pm_desc+'</i></p>'+
						'<p class="weight">'+obj[i].specifics+'</p>'+
						'<p class="price"><span class="price_now">￥'+obj[i].price+'</span>'+
						'<span>￥'+obj[i].market_price+'</span></p></div>'+
						'<div class="jiajian"><div class="jian">-</div><div class="jiajian_num">0'+
						'</div><div class="add"></div></div></div></li>';
					}
					$('.menu_ul').html(html);
					Add.shoppingADD();
					lazyLoad();
					lan();
				}
					
			}
		});
	}
	function ulSpan(){
		$('.ul>li').on('click',function(){
			$('.ul li span').removeClass('span');
			$('.ul li span').eq($(this).index()).addClass('span');
			rexiao($(this).text().trim());
		})
	}
	/***懒加载**/
	function lazyLoad(){
		$('#main_right').on('scroll',function(){
//			console.log($(this).scrollTop())
			lan();
		})
	}
	function lan(){
		var img = $('#main_right').find('[data-src]');
		for(var i=0;i<img.length;i++){
			if($(img[i]).offset().top<=$('#main_right').height()+$('#main_right').scrollTop())(
				$(img[i]).attr('src',$(img[i]).attr('data-src'))
			)
			
		}
	}
	return {
		chao : chao
	}
})